package businessServlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;

import controller.Controller;

@SuppressWarnings("serial")
public class AdClicked extends HttpServlet {
	
	ImagesService imagesService = ImagesServiceFactory.getImagesService(); 
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		resp.getWriter().println("post =)");
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String AdKey = (String)req.getParameter("AdKey");
		String webSite = Controller.getInstance().adClicked(Long.parseLong(AdKey));
		resp.sendRedirect(webSite);
		
	}
}
